import { action, makeAutoObservable, observable } from 'mobx'

class NetworkError {
  code = 0
  reason = ''

  constructor() {
    makeAutoObservable(this, {
      code: observable,
      reason: observable,
      setCode: action,
      setReason: action,
      reset: action
    })
  }

  setCode(code) {
    this.code = code
  }

  setReason(reason) {
    this.reason = reason
  }

  reset() {
    this.code = 0
    this.reason = ''
  }
}

export const netError = new NetworkError()